package edu.gatech.volt2.drdoommgt.presenter;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import edu.gatech.volt2.drdoommgt.domain.*;
import edu.gatech.volt2.drdoommgt.gui.*;
import edu.gatech.volt2.drdoommgt.system.DataBaseAccessor;

public class PatientPresenter implements ActionListener{

	private DataBaseAccessor dba;
	private Patient myPatient;
	private IPatientView myView;
	
	public PatientPresenter (Patient patient, IPatientView view) {
		myPatient = patient;
		myView = view;
		myView.addListener(this);
		myView.showSelf();
	}
	
	public PatientPresenter(Patient patient, DataBaseAccessor db) {
		myPatient = patient;
		dba = db;
		myView = new PatientWindow();
		myView.addListener(this);
		myView.showSelf();
	}

	public void actionPerformed(ActionEvent action) {
		System.out.println(action.getSource());
		System.out.println(myView.getExitButton());
		if ( action.getSource() == myView.getExitButton()){
			System.out.println("Exiting..");
			System.exit(0);
		}
		else if ( action.getSource() == myView.getAppointmentButton() ){
			System.out.println("Opening appointment window..");
			// Do saving here
			AppointmentPresenter presRec = new AppointmentPresenter(dba, this.myPatient );
			
		}
		else if ( action.getSource() == myView.getMedHistButton() ){
			PatientHealthHistoryPresenter presRec = new PatientHealthHistoryPresenter(this.myPatient,dba);		
		}
	}
	
}
